const path = require('path')
// const appData = require('./data.json')
// const programs = appData.programs
// const rules = appData.rules
// const awards = appData.awards
// const user = appData.user

function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  devServer: {
    host: '10.10.11.49',
    port: 8081,
    proxy: {
      '/api/*': {
        target: 'http://10.10.11.49:8080/',
        changeOrigin: true,
        pathRewrite: { '^/api': '' }
      }
    }
    /* before (app) {
      app.get('/api/programs', function (req, res) {
        res.json({
          errno: 0,
          data: programs
        })
      })
      app.get('/api/rules', function (req, res) {
        res.json({
          errno: 0,
          data: rules
        })
      })
      app.get('/api/awards', function (req, res) {
        res.json({
          errno: 0,
          data: awards
        })
      })
      app.get('/api/user', function (req, res) {
        res.json({
          errno: 0,
          data: user
        })
      })
    } */
  },
  chainWebpack(config) {
    config.resolve.alias
      .set('components', resolve('src/components'))
      .set('common', resolve('src/common'))
      .set('api', resolve('src/api'))
  }
}
